<include file="Public:header"/>
<script type="text/javascript" src="__WEBPUBLIC__/Admin/js/ajax-operate.js"></script>
<!--主页面-->
<div id="main-content" class="content">
    <div class="page-header page-header1 clearfix">
        <h3>参会用户</h3>
        <ul class="nav nav-tabs">
            <li class="active">
                <a>新加</a>
            </li>
        </ul>
    </div>
    <div class="search-content">
        <form action="{:U('User/userlist')}" method="post" class="search-form form-inline" role="form">
            <div class="form-group">
                <label class="sr-only" for="title">用户名称</label>
                <input class="earch-input form-control" id="title" type="text" name="nick_name" value="{$_REQUEST['nick_name']}" placeholder="用户名称"/>　
            </div>
            <button type="submit" class="btn derive">查询</button>
        </form>
    </div>
    <div class="content-box-table content-box-content">
        <form>
            <table class="table table-striped table-framed table-hover">
                <thead>
                    <tr>
                        <th width="8%">
                            编号
                        </th>
                        <th>姓名
                        </th>
                        <th>头像</th>
                        <th>性别</th>
                        <th>加入时间</th>
                    </tr>
                </thead>
                <tbody class="tbody">
                    <if condition="empty($list)">
                        <tr><td colspan="20"><span style="font-size:14px;">暂无数据</span></td></tr>
                    </if>
                    <volist name="list" id="vo">
                        <tr>
                            <td>{$vo['id']}</td>
                            <td>{$vo['uname']}</td>
                            <td>
                                <img src="{$vo['photo']}" style="width:50px;"/>
                                
                            </td>
                            <td>
                            <if condition="$vo['sex'] eq 1">
                                男
                                <else/>
                                女
                            </if>
                            </td>
                            <td>{$vo['addtime']|date='Y-m-d H:i:s',###}</td>
                        </tr>
                    </volist>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="20">
                            <div class="fr">
                                {$page}
                            </div>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </form>
    </div>
</div>
<div id="sou" style="text-align:center;display:none;">
    <div style="padding:20px;">
        <form>
        <div><input type="number" class="num text-input form-control" placeholder="上课次数"/></div>
        <div>
            <select class="tid form-control" name="tid" placeholder="请选择教练">
                <option value="">请选择教练</option>
                <volist name="teaclist" id="teac">
                    <option value="{$teac['id']}">{$teac['name']}</option>
                </volist>
            </select>
        </div>
        <div class="kcdiv">
            
        </div>
        <div>
            <button type="button" class="btn commit">确认</button>
        </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var id ;
    $(document).ready(function(){
        $(".modify").on('click',function () {
        id = $(this).data("id");
        var index = layer.open({
            type:1,
            title: '请输入课程内容',
            content: $('#sou'),
            area:["300px","220px"]
        });
        });
    });

    $(".commit").on('click',function () {
        var kid = $(".kid").val();
        var tid = $(".tid").val();
        var num = $(".num").val();
        if (kid && tid && num) {
            $.ajax({
                "url":"{:U('User/buykc')}",
                "type":"post",
                "data":{"kid":kid,"tid":tid,"uid":id,"num":num},
                "dataType":"json",
                "success":function ( res ) {
                    if (res.flag == "success") {
                        layer.closeAll();
                        layer.msg(res.message);
                    }else{
                        layer.msg(res.message);
                    }
                }
            });
        }else{
            layer.msg("请填写完整信息！");
        }
    });

    $(".tid").on('change',function () {
            var tid = $(this).val();
            if (!tid) {
                layer.msg("请先选择教练！");
                $(".kcdiv").html("");
            }
            $.ajax({
                url:"{:U('User/getkc')}",
                data:{tid:tid},
                dataType:"json",
                type:"post",
                success:function ( res ) {
                    if ( res.flag == "success" ) {
                        var jkc = res.data;
                        console.log(jkc);
                        var str = '<select class="kid form-control" name="kid" placeholder="请选择课程">';
                        for(var index in jkc){
                            var obj = jkc[index];
                            str += '<option value="'+obj['kid']+'">'+obj['name']+'</option>';
                        }
                        str += '</select>';
                        $(".kcdiv").html( str );
                    }else{
                        layer.msg(res.message);
                    }
                }
            })
        });
</script>
<include file="Public:footer"/>
